package com.icoolkj.mall.product.mapper;


import com.icoolkj.mall.product.dto.ProductResponse;
import com.icoolkj.mall.product.model.Product;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface ProductMapper {

    @Insert("INSERT INTO product (product_name, product_description, product_price, create_time, update_time) VALUES (#{productName}, #{productDescription}, #{productPrice}, #{createTime}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyColumn = "product_id", keyProperty = "productId")
    int createProduct(Product product);

    @Select("SELECT * FROM product order by product_id desc")
    List<ProductResponse> getAllProducts();

    @Select("SELECT * FROM product where product_id = ${productId}")
    ProductResponse getPriceProduct(@Param("productId") Long productId);
}
